<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: bobo
  Date: 16-10-28
  Time: 下午3:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <jsp:include page="../layout/head.jsp"/>
</head>
<body>

    <div class="panel admin-panel">
        <div class="panel-head"><strong class="icon-reorder"> 用户列表</strong></div>
        <table class="table table-hover text-center">
            <tr>
                <th>姓名</th>
                <th>电话</th>
                <th>邮箱</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${page.list}" var="user">
            <tr>
                <td>${user.name}</td>
                <td>${user.phone}</td>
                <td>${user.email}</td>
                <td>
                    禁 言<input type="radio" class="${user.id}" name="${user.id}status" value="0" ${user.status ==0 ?"checked":""} onchange="radioValue(this)"><br>
                    正 常<input type="radio" class="${user.id}" name="${user.id}status" value="1" ${user.status ==1 ?"checked":""} onchange="radioValue(this)">
                </td>
            </tr>
            </c:forEach>
            <tr>
                <td colspan="5">
                    <jsp:include page="../layout/pager.jsp">
                        <jsp:param name="pageNum" value="${page.pageNum}"/>
                        <jsp:param name="current" value="${page.current}"/>
                        <jsp:param name="pageSize" value="${page.pageSize}"/>
                        <jsp:param name="url" value="${pageContext.request.contextPath}/admin/user/getUsers"/>
                    </jsp:include>
                </td>
            </tr>
        </table>
    </div>
    <script>
        function radioValue(node) {
            $.ajax({
                url:"${pageContext.request.contextPath}/admin/user/changeStatus",
                type:"get",
                data:{"id":node.className,"status":node.value},
                success : function (data) {
                    if(data == "true"){
                        alert("修改成功");
                    }
                },
                error:function () {
                    alert("失败");
                }
            })
        }
    </script>

<jsp:include page="../layout/footer.jsp"/>
</body>
</html>
